package org.grottarossa.ui;


import java.util.Date;
import java.util.GregorianCalendar;

import org.apache.commons.beanutils.converters.DateConverter;


public class DateHelper
{
	public static String datePattern = "dd-MM-yyyy";

	public static String DateToString(Date dateToConvert)
	{
		DateConverter converter = new DateConverter();
		converter.setPattern(datePattern);
		return (String) converter.convert(String.class, dateToConvert);
	}

	public static Date StringToDate(String sDateToConvert)
	{
		DateConverter converter = new DateConverter();
		converter.setPattern(datePattern);
		return (Date) converter.convert(Date.class, sDateToConvert);
	}

	public static GregorianCalendar StringToGregorianCalendar(String sCalendar)
	{
		DateConverter converter = new DateConverter();
		converter.setPattern(datePattern);
		Date d = (Date) converter.convert(Date.class, sCalendar);
		GregorianCalendar result = new GregorianCalendar();
		result.setTime(d);
		return result;
	}

	public static GregorianCalendar DateToGregorianCalendar(Date dCalendar)
	{
		GregorianCalendar result = new GregorianCalendar();
		result.setTime(dCalendar);
		return result;
	}
}
